package day27.edu;

import org.junit.Test;

import java.util.*;

// Created: 27/09/2025, ChangJiang Ru
public class CollectionsTest {
    @Test
    public void test1()
    {
        List list = Arrays.asList(34, 32, 54, 43, 21, 24, 63, 93, 62, 64, 52, 21);

        // Collections.frequency()
        int count = Collections.frequency(list, 21);
        System.out.println(count);

        System.out.println("===========");

//        List dest = new ArrayList();

        List dest = new ArrayList();
        System.out.println(dest.size());
        System.out.println(list.size());

        // Collection.copy(dest, src)
//        Collections.copy(dest, list);

        System.out.println(dest);
    }

    @Test
    public void test2()
    {
        List src = Arrays.asList(34, 32, 54, 43, 21, 24, 63, 93, 62, 64, 52, 21);

        List dest = Arrays.asList(new Object[src.size()]);

        Collections.copy(dest, src);

        System.out.println(dest);
    }

    @Test
    public void test3()
    {
        List list = new ArrayList();
        list.add(12);
        list.add(13);
        list.add(17);

        List list1 = Collections.unmodifiableList(list);
//        list1.add(11);

        System.out.println(list1.get(0));

    }
    
    @Test
    public void test4()
    {
        List list1 = new ArrayList();

        List list2 = Collections.synchronizedList(list1);
        System.out.println(list2);

        HashMap map = new HashMap();
        Map map1 = Collections.synchronizedMap(map);
        System.out.println(map1);
    }
}
